home *** CD-ROM | disk | FTP | other *** search
- 'This is the module for the CompuServe zip file application.
-
- Dim mFileLen As Long
-
- Sub Startup ()
-
- gsFName = "ComServe.dat" 'File name.
- giFileLen = Len(gComServeRec) 'Record length.
-
- OpenFile
- SizeOfFile& = LOF(giFileNo)
- Close giFileNo
- giNoOfRecs = SizeOfFile& / giFileLen
- ReDim gSortData(giNoOfRecs)
-
- End Sub
-
- Sub SaveRec ()
-
- OpenFile
-
- If (gAddRec) Then 'Add a new record to the end of the file.
- 'Calculate the number of records currently.
-
- mFileLen = LOF(giFileNo)
- giNoOfRecs = (mFileLen / Len(gComServeRec)) + 1
- gComServeRec.RecNo = giNoOfRecs
-
- giIndex = giNoOfRecs
-
- End If
-
- Put giFileNo, giIndex, gComServeRec
-
- Close giFileNo
-
- If (gModRec) Then 'Return to the list.
- Load ComSList
- ComSList.Show
- Unload OneRec
- End If
-
-
-
- End Sub
-
- Sub OpenFile ()
- 'Opens the file.
-
- giFileNo = FreeFile 'Get a file number.
-
- Open gsFName For Random As giFileNo Len = giFileLen
-
- End Sub
-
- Function IsPrint (TheChar As String) As Integer
- 'Checks to see if the char is printable.
-
- AsciiVal% = Asc(TheChar)
-
- If ((AsciiVal% > 32) And (AsciiVal% < 127)) Then
- IsPrint = True
- Else
- IsPrint = False
- End If
-
- End Function
-
- Function StringMatch (sSearch As String, sFind As String) As Integer
- 'Used in the search routines.
- 'This matches any occurance to the find string in the search string.
- 'You need to add code to match whole words only.
-
- result% = InStr(sSearch, sFind)
-
- If (result% > 0) Then
- StringMatch = True
- Else
- StringMatch = False
- End If
-
- End Function
-
- Function GetFileName (sSearch As String) As String
- 'Parse out the file name from the string.
- 'If not found return the empty string.
-
- iPosition& = InStr(sSearch, ".") 'Remember the file names need the extension.
- If iPosition& > 0 Then
- GetFileName = Left$(sSearch, iPosition& + 3) + Chr$(0)
- Else
- GetFileName = "" + Chr$(0)
- End If
-
- End Function
-
- Sub BuildFileKey ()
- 'This subroutine builds the sort data structure.
-
- gSortData(glArrayIndex).RecNo = gComServeRec.RecNo
- gSortData(glArrayIndex).FileName = gComServeRec.FileName
- gSortData(glArrayIndex).CompuServeID = gComServeRec.CompuServeID
- gSortData(glArrayIndex).Author = gComServeRec.Author
- gSortData(glArrayIndex).Company = gComServeRec.Company
- gSortData(glArrayIndex).Title = gComServeRec.Title
- glArrayIndex = glArrayIndex + 1
-
- End Sub
-
- Function GetFileIndex (sFileName As String) As Long
- 'This function returns the record index for loading from the file.
- 'Returns 0 if it is not found.
-
- i% = 0
- sFileName = LTrim$(RTrim$(sFileName)) 'Get rid of extra spaces.
-
- 'Search the sort data structure arrays for a matching file name.
- 'If you find one then return the record index of the file.
-
- Do
- sTempStr$ = gSortData(i%).FileName 'I tried this using the array element but it won't work.
- sTempStr$ = LTrim$(RTrim$(sTempStr$)) + Chr$(0) 'So this is a hack to make it work.
- If sTempStr$ = sFileName Then
- GetFileIndex = gSortData(i%).RecNo
- Exit Function
- End If
- i% = i% + 1
- Loop Until i% > glArrayIndex 'Loop until you have checked all the file names.
-
- GetFileIndex = 0 'Didn't find it.
- End Function
-
- Sub ChgFileName (FileName As String, NewName As String)
- For Index& = 0 To glArrayIndex
- If (gSortData(i&).FileName = FileName) Then
- gSortData(i&).FileName = NewName
- Exit Sub
- End If
- Next Index&
- End Sub
-
-